<?php

    namespace Product\Controller;

    use Common\Controller\AdminbaseController;

    class AdminSettingController extends AdminbaseController {

        protected $options_model;

        function _initialize() {
            parent::_initialize();
            $this->options_model = D("Common/Options");
        }


        // 添加商品
        public function add(){
            $item = $this->options_model->where(array('option_name'=>'site_setting'))->find();
            $item = unserialize($item['option_value']);
            $this->assign('item',$item);
            $this->display();
        }

        // 文章添加提交
        public function add_post(){
            if (IS_POST) {
                $data = array(
                    'site_top'=>I("post.site_top"),
                    'site_banquan'=>I("post.site_banquan"),
                    'site_beian'=>I("post.site_beian"),
                    'webname'=>I("post.webname"),
                    'header_ico'=>I("post.header_ico"),
                    'logo'=>I("post.logo"),
                );
                $result = $this->options_model->where(array('option_name'=>'site_setting'))->save(array('option_value'=>serialize($data)));
                if ($result) {
                    $this->success("添加成功！",U('AdminSetting/add'));
                } else {
                    $this->error("添加失败！");
                }

            }
        }

    }